/**
 * 
 */
package cc.w3d.gwitjeds.realtimechangetextbox.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.TextBox;

public class RealTimeChangeTextBox extends TextBox
{
	private static void addOnPasteEvent(com.google.gwt.user.client.Element e, com.google.gwt.user.client.Command c)
	{
		RealTimeChangeDomEventLoader domEvent = GWT.create(RealTimeChangeDomEventLoader.class);
		domEvent.addOnPasteEvent(e, c);
	};

	final private HandlerManager handlerManager = new HandlerManager(this);

	public RealTimeChangeTextBox()
	{
		addOnPasteEvent(this.getElement(), new Command()
		{
			@Override
			public void execute() {handlerManager.fireEvent(new RealTimeChangeEvent(getValue()));}
		});
	}

	public void addRealTimeChangeHandler(RealTimeChangeHandler handler)
		{handlerManager.addHandler(RealTimeChangeEvent.getType(), handler);}
}